﻿using System;

namespace UltimateNavigationFramework.UriNavigation
{
    public class UltimateNavigationUriMapping : IUltimateNavigationUriMapping
    {
        #region Private members
        private System.Windows.Navigation.UriMapping _internalMapping; 
        #endregion

        #region Properties
        public bool IsChildFrame { get; set; }

        /// <summary>
        /// Gets or sets the pattern to match when determining if the requested uniform resource identifier (Uri) is converted to a mapped Uri.
        /// </summary>
        public Uri Uri
        {
            get
            {
                return _internalMapping.Uri;
            }
            set
            {
                _internalMapping.Uri = value;
            }
        }

        /// <summary>
        /// Gets or sets the uniform resource identifier (Uri) that is navigated to instead of the originally requested Uri.
        /// </summary>
        public Uri MappedUri
        {
            get
            {
                return _internalMapping.MappedUri;
            }
            set
            {
                _internalMapping.MappedUri = value;
            }
        } 
        #endregion

        #region Constructor
        /// <summary>
        /// Constructs the Uri Mapping
        /// </summary>
        public UltimateNavigationUriMapping()
        {
            _internalMapping = new System.Windows.Navigation.UriMapping();
        } 
        #endregion

        #region Map URI
        /// <summary>
        /// Converts the specified uniform resource identifier (Uri) to a new Uri, if the specified Uri matches the defined template for converting.
        /// </summary>
        /// <param name="uri">The Uri to convert.</param>
        /// <returns>The Uri that has been converted or null if the Uri cannot be converted.</returns>
        public Uri MapUri(Uri uri)
        {
            return _internalMapping.MapUri(uri);
        } 
        #endregion
    }
}
